home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Applications 1997 August / SGI IRIX 6.4 Applications 1997 August.iso / dist / arraysvcs.idb / usr / include / arraysvcs.h.z / arraysvcs.h
Encoding:
C/C++ Source or Header  |  1997-02-07  |  12.9 KB  |  378 lines

  1. #ifndef __ARRAYSVCS_H__
  2. #define __ARRAYSVCS_H__
  3.  
  4. /*
  5.  * arraysvcs.h
  6.  *
  7.  *    Interfaces for the array services library
  8.  *
  9.  * Copyright 1995, Silicon Graphics, Inc.
  10.  * ALL RIGHTS RESERVED
  11.  *
  12.  * UNPUBLISHED -- Rights reserved under the copyright laws of the United
  13.  * States.   Use of a copyright notice is precautionary only and does not
  14.  * imply publication or disclosure.
  15.  *
  16.  * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
  17.  * Use, duplication or disclosure by the Government is subject to restrictions
  18.  * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
  19.  * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
  20.  * in similar or successor clauses in the FAR, or the DOD or NASA FAR
  21.  * Supplement.  Contractor/manufacturer is Silicon Graphics, Inc.,
  22.  * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
  23.  *
  24.  * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
  25.  * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
  26.  * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
  27.  * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
  28.  * GRAPHICS, INC.
  29.  */
  30.  
  31. #ident "$Revision: 1.34 $"
  32.  
  33. #if defined(_LANGUAGE_C_PLUS_PLUS)
  34. extern "C" {
  35. #endif
  36.  
  37. #include <sys/types.h>
  38. #include <netinet/in.h>
  39.  
  40. #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
  41.  
  42.  
  43. /*
  44.  * error handling
  45.  *    Most array services store a result code in the global variable
  46.  *    "aserrorcode".  This result code may actually contain several
  47.  *    fields.  A general summary of the error code, similar to the
  48.  *    standard "errno", can be found in "aserrno".
  49.  */
  50.  
  51. /* Error code declarations */
  52. typedef __uint32_t aserror_t;
  53.  
  54. #define aserrnoc(E)    ((E) & 255)
  55. #define aserrwhatc(E)  (((E) >> 8) & 255)
  56. #define aserrwhyc(E)   (((E) >> 16) & 255)
  57. #define aserrextrac(E) ((E) >> 24)
  58.  
  59. extern aserror_t aserrorcode;
  60.  
  61. #define aserrno    (aserrnoc(aserrorcode))
  62. #define aserrwhat  (aserrwhatc(aserrorcode))
  63. #define aserrwhy   (aserrwhyc(aserrorcode))
  64. #define aserrextra (aserrextrac(aserrorcode))
  65.  
  66.  
  67. /* Error summary numbers */
  68. #define ASE_OK        0        /* Operation successful */
  69. #define ASE_SYSERROR    1        /* System operation failed */
  70. #define ASE_BADVALUE    2        /* Invalid value/argument */
  71. #define ASE_REQFAILED    3        /* Request failed */
  72. #define ASE_BADCOMMAND    4        /* Invalid command */
  73. #define ASE_PROTOCOL    5        /* Protocol error */
  74. #define ASE_INTERNAL    6        /* Internal error */
  75. #define ASE_NOARRAYSVCS 7        /* Array services not installed */
  76.  
  77. /* ASE_OK "why" codes ("what" is undefined) */
  78. #define ASOK_COMPLETED    0        /* Command/request completed */
  79. #define ASOK_INITIATED    1        /* Command started, may not be done */
  80. #define ASOK_CONNECT    2        /* Initiate connection */
  81. #define ASOK_CONNECTED    3        /* Connection completed */
  82.  
  83. /* ASE_NOARRAYSVCS has no "what" or "why" code */
  84.  
  85. /* ASE_SYSERROR "what" codes.  ("why" == errno) */
  86. #define ASSE_UNKNOWN    0        /* Origin unknown */
  87. #define ASSE_CMDFORK    1        /* Command process fork */
  88. #define ASSE_REQFORK    2        /* Request process fork */
  89. #define ASSE_WAIT    3        /* Wait for process */
  90. #define ASSE_SELECT    4        /* Wait for event */
  91. #define ASSE_READHDR    5        /* Read message header */
  92. #define ASSE_READBODY    6        /* Read message body */
  93. #define ASSE_WRITEHDR    7        /* Write message header */
  94. #define ASSE_WRITEBODY    8        /* Write message body */
  95. #define ASSE_GETASH    9        /* Extract ASH */
  96. #define ASSE_PIDSINASH    10        /* Extract PIDs in ASH */
  97. #define ASSE_ACCEPT    11        /* Accept client connection */
  98. #define ASSE_SOCKET    12        /* Create socket */
  99. #define ASSE_CONNECT    13        /* Connect to server */
  100. #define ASSE_SETSOCKOPT 14        /* Set socket options */
  101. #define ASSE_BIND    15        /* Bind name to socket */
  102. #define ASSE_LISTEN    16        /* Listen for connections */
  103. #define ASSE_WRITEOUT    17        /* Write output data */
  104. #define ASSE_OPENPROCD    18        /* Open procfs directory */
  105. #define ASSE_OPENOUT    19        /* Open output file */
  106. #define ASSE_STATOUT    20        /* Stat output file */
  107. #define ASSE_READOUT    21        /* Read output file */
  108. #define ASSE_ENUMASHS    22        /* Enumerate ASHs */
  109. #define ASSE_PEERNAME    23        /* Get peer name */
  110. #define ASSE_SOCKNAME    24        /* Get socket name */
  111. #define ASSE_STATUDS    25        /* Stat unix domain socket */
  112. #define ASSE_IOCTLNBIO    26        /* Make socket non-blocking */
  113. #define ASSE_GETSRVOPT  27        /* Get server option */
  114.  
  115. /* ASE_BADVALUE "what" codes */
  116. #define ASBV_UNKNOWN    0        /* Unknown value */
  117. #define ASBV_PORTNUM    1        /* Port number */
  118. #define ASBV_ARRAY    2        /* Array name */
  119. #define ASBV_HOST    3        /* Host name */
  120. #define ASBV_SRVTOKEN    4        /* Server token */
  121. #define ASBV_OPTNAME    5        /* Option name */
  122. #define ASBV_OPTVAL    6        /* Option value */
  123. #define ASBV_PID    7        /* Process ID */
  124. #define ASBV_DEST       8        /* Destination */
  125. #define ASBV_CONNECT    9        /* Connection info */
  126. #define ASBV_ADDRFAMILY 10        /* Address family */
  127.  
  128. /* ASE_BADVALUE "why" codes */
  129. #define ASBVY_UNKNOWN    0        /* Do not know why */
  130. #define ASBVY_RANGE    1        /* Value out of range */
  131. #define ASBVY_PARSE    2        /* Cannot parse value */
  132. #define ASBVY_NOTFOUND    3        /* Value not found */
  133. #define ASBVY_SIZE    4        /* Size of value is invalid */
  134. #define ASBVY_INVALID    5        /* Value generally invalid */
  135. #define ASBVY_NODEFAULT 6        /* No default for unspecified value */
  136.  
  137. /* ASE_REQFAILED "why" codes  ("what" is undefined) */
  138. #define ASRFY_UNKNOWN    0        /* Do not know why */
  139. #define ASRFY_VERSION    1        /* Wrong version of arrayd */
  140. #define ASRFY_TIMEOUT    2        /* Timed out waiting for command */
  141. #define ASRFY_BADOS    3        /* Wrong version of IRIX */
  142. #define ASRFY_NOCONNECT    4        /* Unable to connect interactively */
  143. #define ASRFY_BADCLIENT 5        /* Client connection invalid */
  144. #define ASRFY_CONNECTTO 6        /* Interactive connection timed out */
  145. #define ASRFY_BADAUTH    7        /* Authentication error */
  146.  
  147. /* ASE_BADCOMMAND "why" codes ("what" is undefined) */
  148. #define ASBCY_UNKNOWN    0        /* Do not know why */
  149. #define ASBCY_NOTFOUND    1        /* Command not found */
  150. #define ASBCY_EMPTY    2        /* Nothing to INVOKE */
  151. #define ASBCY_BADUSER    3        /* Invalid USER */
  152. #define ASBCY_BADGROUP    4        /* Invalid GROUP */
  153. #define ASBCY_BADPROJ    5        /* Invalid PROJECT */
  154. #define ASBCY_ILLMERGE  6        /* MERGE illegal for request */
  155. #define ASBCY_NOINFO    7        /* No command info provided */
  156.  
  157. /* Error functions */
  158. aserror_t asmakeerror(int, int, int, int);
  159. void asperror(const char *, ...);
  160. const char *asstrerror(aserror_t);
  161.  
  162.  
  163. /*
  164.  * Server functions
  165.  *    Most array commands take an optional "asserver_t" argument to
  166.  *    specify an array server other than the default. These functions
  167.  *    create/destroy these tokens and modify options associated with them.
  168.  */
  169. typedef const void *asserver_t;
  170.  
  171. typedef __uint64_t askey_t;
  172. #define AS_NOKEY    0    /* No key specified */
  173.  
  174. asserver_t asopenserver(const char *, int);
  175. void       ascloseserver(asserver_t);
  176.  
  177. int asdfltserveropt(int, void *, int *);
  178. int asgetserveropt(asserver_t, int, void *, int *);
  179. int assetserveropt(asserver_t, int, const void *, int);
  180.  
  181. /* Server option names */
  182. #define AS_SO_TIMEOUT    1    /* Response timeout value */
  183. #define AS_SO_CTIMEOUT    2    /* Connection timeout value */
  184. #define AS_SO_FORWARD    3    /* Forwarding on/off */
  185. #define AS_SO_LOCALKEY  4    /* Local authentication key */
  186. #define AS_SO_REMOTEKEY 5    /* Remote authentication key */
  187. #define AS_SO_PORTNUM    6    /* Port number (dflt only) */
  188. #define AS_SO_HOSTNAME    7    /* Host name (dflt only) */
  189.  
  190.  
  191. /*
  192.  * ASH functions
  193.  */
  194. ash_t asallocash(asserver_t, const char *);
  195. int   asashisglobal(ash_t);
  196. ash_t asashofpid(pid_t);
  197.  
  198. typedef struct aspidlist {
  199.     int    numpids;        /* Number of PIDs in list */
  200.     pid_t   *pids;            /* Array of PIDs */
  201. } aspidlist_t;
  202.  
  203. aspidlist_t *aspidsinash(ash_t);
  204.  
  205.  
  206. /*
  207.  * Array command functions
  208.  */
  209. typedef struct ascmdreq {
  210.     char    *array;        /* Name of target array */
  211.     int    flags;        /* Option flags */
  212.     int    numargs;    /* Number of arguments */
  213.     char    **args;        /* Cmd arguments (ala argv) */
  214.     int    ioflags;    /* I/O flags for interactive commands */
  215.  
  216.     char    rsrvd[100];    /* reserved for expansion: init to 0's */
  217. } ascmdreq_t;
  218.  
  219. #define ASCMDREQ_LOCAL        0x80000000    /* Do not broadcast to array */
  220. #define ASCMDREQ_NEWSESS    0x40000000    /* Start new array session */
  221. #define ASCMDREQ_OUTPUT        0x20000000    /* Collect output from cmd */
  222. #define ASCMDREQ_NOWAIT        0x10000000    /* Do not wait on command */
  223. #define ASCMDREQ_INTERACTIVE    0x08000000    /* Run interactively */ 
  224.  
  225. #define ASCMDIO_STDIN        0x80000000    /* Provide stdin to command */
  226. #define ASCMDIO_STDOUT        0x40000000    /* Provide stdout to command */
  227. #define ASCMDIO_STDERR        0x20000000    /* Provide stderr to command */
  228. #define ASCMDIO_SIGNAL        0x10000000    /* Send signals to command */
  229. #define ASCMDIO_OUTERRSHR    0x08000000    /* Provide stderr via stdout */
  230.  
  231. #define ASCMDIO_FULLIO        (ASCMDIO_STDIN  | \
  232.                  ASCMDIO_STDOUT | \
  233.                  ASCMDIO_STDERR | \
  234.                  ASCMDIO_SIGNAL)    /* Provide full I/O */
  235.  
  236.  
  237. typedef struct ascmdrslt {
  238.     char      *machine;    /* Name of responding machine */
  239.     ash_t      ash;        /* ASH of running command */
  240.     int      flags;    /* Result flags */
  241.     aserror_t error;    /* Error code for this command */
  242.     int      status;    /* Exit status */
  243.     char      *outfile;    /* Name of output file */
  244.  
  245.     int      ioflags;    /* I/O connections (see ascmdreq_t) */
  246.     int      stdinfd;    /* File descriptor for command's stdin */
  247.     int      stdoutfd;    /* File descriptor for command's stdout */
  248.     int      stderrfd;    /* File descriptor for command's stderr */
  249.     int      signalfd;    /* File descriptor for sending signals */
  250.  
  251.     /* stay tuned for future expansion */
  252. } ascmdrslt_t;
  253.  
  254. #define ASCMDRSLT_OUTPUT    0x80000000    /* Output available */
  255. #define ASCMDRSLT_MERGED    0x40000000    /* Output is merged */
  256. #define ASCMDRSLT_ASH        0x20000000    /* ASH is available */
  257. #define ASCMDRSLT_INTERACTIVE    0x10000000    /* I/O connections available */
  258.  
  259.  
  260. typedef struct ascmdrsltlist {
  261.     int    numresults;    /* Number of ascmdrslt_t's */
  262.     ascmdrslt_t **results;    /* Array of ascmdrslt_t pointers */
  263. } ascmdrsltlist_t;
  264.  
  265.  
  266. ascmdrsltlist_t *ascommand(asserver_t, const ascmdreq_t *);
  267.  
  268.  
  269.  
  270. /*
  271.  * aslist<> functions
  272.  *    These functions return a malloc'ed list of items of the specified
  273.  *    type containing configuration or status information. The corresponding
  274.  *    "asfree<>" functions may be used to release the storage allocated by
  275.  *    the "aslist<>" functions.
  276.  */
  277. typedef struct asarray {
  278.     const char *name;        /* Name of array */
  279.     int       numattrs;        /* Number of attribute strings */
  280.     const char **attrs;        /* List of attribute strings */
  281.     u_short       ident;        /* Array ID */
  282. } asarray_t;
  283.  
  284. typedef struct asarraylist {
  285.     int      numarrays;        /* Number of arrays in list */
  286.     asarray_t **arrays;        /* Array of asarray_t pointers */
  287. } asarraylist_t;
  288.  
  289. asarray_t *asgetdfltarray(asserver_t);
  290. asarraylist_t *aslistarrays(asserver_t);
  291.  
  292.  
  293. typedef struct asashlist {
  294.     int    numashs;        /* Number of ASHs in list */
  295.     ash_t   *ashs;            /* Array of ASHs */
  296. } asashlist_t;
  297.  
  298. asashlist_t *aslistashs(asserver_t, const char *Array, int Dest, int Flags);
  299. asashlist_t *aslistashs_array(asserver_t, const char *);
  300. asashlist_t *aslistashs_local(void);
  301. asashlist_t *aslistashs_server(asserver_t);
  302.  
  303. /* Destination flags */
  304. #define ASDST_NONE   0            /* Destination not specified */
  305. #define ASDST_LOCAL  1            /* Local machine only */
  306. #define ASDST_SERVER 2            /* Specified server only */
  307. #define ASDST_ARRAY  3            /* Specified array */
  308.  
  309. /* Control flags for aslistashs */
  310. #define ASLAF_NOLOCAL    0x00000001    /* Global ASHs only */
  311. #define ASLAF_NODUPES    0x00000002    /* Remove duplicate ASHs */
  312.  
  313.  
  314. typedef struct asmachine {
  315.     const char *name;        /* Familiar name of machine */
  316.     const char *hostname;        /* Network hostname of machine */
  317.     int       numattrs;        /* Number of attribute strings */
  318.     const char **attrs;        /* List of attribute strings */
  319.     struct in_addr inaddr;        /* IP address of machine */
  320.     u_short       portnum;        /* Port # of array daemon */
  321.     u_short       ident;        /* ID of array daemon */
  322. } asmachine_t;
  323.  
  324. typedef struct asmachinelist {
  325.     int    nummachines;        /* Number of machines in list */
  326.     asmachine_t **machines;        /* Array of asmachine_t pointers */
  327. } asmachinelist_t;
  328.  
  329. asmachinelist_t *aslistmachines(asserver_t, const char *ArrayName);
  330.  
  331.  
  332. /*
  333.  * asfree<> functions
  334.  *    These functions are used to release the storage allocated by other
  335.  *    libarray functions (e.g. the aslist<> functions)
  336.  */
  337. void asfreearray(asarray_t *, int);
  338. void asfreearraylist(asarraylist_t *, int);
  339. void asfreeashlist(asashlist_t *, int);
  340. void asfreecmdrslt(ascmdrslt_t *, int);
  341. void asfreecmdrsltlist(ascmdrsltlist_t *, int);
  342. void asfreemachine(asmachine_t *, int);
  343. void asfreemachinelist(asmachinelist_t *, int);
  344. void asfreepidlist(aspidlist_t *, int);
  345.  
  346. #define ASFLF_FREEDATA    0x80000000    /* Free individual list items */
  347. #define ASFLF_UNLINK    0x40000000    /* Unlink temporary files */
  348. #define ASFLF_CLOSEIO    0x20000000    /* Close I/O connections */
  349.  
  350.  
  351.  
  352. /*
  353.  * Constants pertaining to ASH's and PRID's
  354.  */
  355. #define ASBADASH    -1LL    /* An invalid Array Session Handle */
  356. #define ASMINASH    0LL    /* Smallest valid Array Session Handle */
  357. #define ASNOASH        0LL    /* "No ASH specified" */
  358. #define ASASHMASK    0x7FFFFFFFFFFFFFFFLL    /* Valid ASH bits */
  359.  
  360. #define ASBADPRID    -1LL    /* An invalid project ID */
  361. #define ASMINPRID    0LL    /* Smallest valid project ID */
  362. #define ASNOPRID    0LL    /* "No project ID specified" */
  363.  
  364.  
  365.  
  366. /*
  367.  * Miscellaneous functions
  368.  */
  369. const char *asgetattr(const char *, const char **, int);
  370.  
  371. #endif /* C || C++ */
  372.  
  373. #if defined(_LANGUAGE_C_PLUS_PLUS)
  374. }
  375. #endif
  376.  
  377. #endif  /* !__ARRAYSVCS_H_ */
  378.